package com.limingru.newbee.service.impl;

import com.limingru.newbee.api.vo.IndexCarouselVO;
import com.limingru.newbee.dao.CarouselMapper;
import com.limingru.newbee.entity.Carousel;
import com.limingru.newbee.service.CarouselService;
import com.limingru.newbee.util.BeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

@Service
public class CarouselServiceImpl implements CarouselService {

    @Autowired
    CarouselMapper carouselMapper;

    @Override
    public List<IndexCarouselVO> getCarouselList() {
        List<Carousel> carousels = carouselMapper.selectAllCarousel();
        if(CollectionUtils.isEmpty(carousels)) {
            return new ArrayList<IndexCarouselVO>();
        }
        return BeanUtil.copyList(carousels, IndexCarouselVO.class);
    }
}
